package rule

import "regexp"

func init() {
	Register(&alphaRule{reg: regexp.MustCompile("^[a-zA-Z]+$")})
}

type alphaRule struct {
	reg *regexp.Regexp
}

func (a *alphaRule) Name() string {
	return "alpha"
}

func (a *alphaRule) Check(in *RuleInput) (err error) {
	if v, ok := in.Value.(string); ok && a.reg.FindStringIndex(v) != nil {
		return
	}
	return in.Error()
}
